package model.dataStructures;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * Implementation of a <code>Map</code> with two keys mapping one value.
 * <p>
 * Internally represented by two <code>HashMap</code>s.
 * The key of the first internal <code>HashMap</code> is K1.
 * The key of the second internal <code>HashMap</code> is K2.
 *   
 * @version %I%, %G%
 *
 * @param <K1> type of the first key (must be a number)
 * @param <K2> type of the second key
 * @param <V> type of the value that should be stored in this <code>Map</code>.
 * @see IDualMap
 * @see HashMap
 * @see Map
 */
public final class DualMap<K1 extends Number, K2, V> implements IDualMap<K1, K2, V> {

	private final Map<K1, V> map1 = new HashMap<K1, V>();

	private final Map<K2, V> map2 = new HashMap<K2, V>();

	@Override
	public void put(K1 key1, K2 key2, V value) {
		map1.put(key1, value);
		map2.put(key2, value);
	}
	
	@Override
	public V get(K1 key){
		return map1.get(key);
	}
	
	@Override
	public V get(K2 key){
		return map2.get(key);
	}
	
	@Override
	public Collection<V> values(){
		return map1.values();
	}
	
	@Override
	public V remove(K1 key, K2 key2){
		V value = map1.remove(key);
		map2.remove(key2);
		return value;
	}
}
